package com.example.myapplication.my_view_model

import android.util.Log
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel

class BasketBallModel: ViewModel() {
    var aScore: MutableLiveData<Int> = MutableLiveData(0)
    var bScore: MutableLiveData<Int> = MutableLiveData(0)

    var lastScoreA: Int = 0
    var lastScoreB: Int = 0
    fun addAScore(s: Int){

        lastScoreA = aScore.value!!
        lastScoreB = bScore.value!!
        aScore.postValue(aScore.value!! + s)
    }

    fun addBScore(s: Int){
        lastScoreB = bScore.value!!
        lastScoreA = aScore.value!!
        bScore.postValue(bScore.value!! + s)
    }

    fun reset(){
        lastScoreB = bScore.value!!
        lastScoreA = aScore.value!!
        bScore.postValue(0)
        aScore.postValue(0)
    }

    fun back(){

        aScore.postValue(lastScoreA)
        bScore.postValue(lastScoreB)
    }
}